//
//  UIImage+CLDraw.m
//  CLExtension
//
//  Created by CharlieLiao on 2017/8/22.
//  Copyright © 2017年 Charlie. All rights reserved.
//

#import "UIImage+CLDraw.h"
#import "ColorHexExtension.h"

@implementation UIImage (CLDraw)

/// 画纯色图 w:1 h:1 长宽各1像素
+ (UIImage*)graphics:(UIColor*)color
{
    return [UIImage graphics:color size:CGSizeMake(1, 1)];
}

/// 画纯色图
+ (UIImage*)graphics:(UIColor*)color size:(CGSize)size
{
    UIGraphicsBeginImageContext(size);
    CGContextRef line = UIGraphicsGetCurrentContext();
    CGContextSetFillColorWithColor(line, color.CGColor);
    CGContextFillRect(line, CGRectMake(0, 0, size.width, size.height));
    CGContextFillPath(line);
    UIImage *result = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    
    return result;
}

/// 画纯色图
+ (UIImage*)hexColor:(NSUInteger)hexValue size:(CGSize)size
{
    return [UIImage graphics:[UIColor hex:hexValue] size:size];
}

/// 画纯色图 w:1 h:1 长宽各1像素
+ (UIImage*)hexColor:(NSUInteger)hexValue
{
    return [UIImage hexColor:hexValue size:CGSizeMake(1, 1)];
}

@end
